package com.sasis.webapp.dwr;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.sasis.model.FlightInfo;
import com.sasis.service.FlightInfoManager;
import com.sasis.util.CopyUtil;
import com.sasis.util.StringUtil;
import com.sasis.webapp.form.FlightInfoForm;

public class FlightInfoDwr {
private FlightInfoManager flightInfoManager; 
	
	public void setFlightInfoManager(FlightInfoManager flightInfoManager) {
		this.flightInfoManager = flightInfoManager;
	}
	
	public FlightInfo getFlightInfo(String flightNum,String flightDate){
		//FlightInfoForm FlightInfoForm=new FlightInfoForm();
		FlightInfo flightInfo = new FlightInfo();
		//FlightInfoForm.setFlightNum(flightNum);
		//FlightInfoForm.setFlightDate(flightDate);
		flightInfo.setFlightNum(flightNum);
		if(!StringUtil.isEmpty(flightDate)){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		    try{
			    Date date = sdf.parse(flightDate);
			    java.sql.Timestamp sqlTimestamp=new java.sql.Timestamp(date.getTime());
			    flightInfo.setFlightDate(sqlTimestamp);
		       // System.out.println(sqlTimestamp);
		    }catch(Exception e){
		       e.printStackTrace();
		    }
			
		}
		//CopyUtil.copy(FlightInfoForm,flightInfo);
		//if(flightInfoManager.getFlightInfo(flightInfo)!=null);
		flightInfo=flightInfoManager.getFlightInfo(flightInfo);
		return flightInfo;
	}
	
	
}